﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace SpaceshipDuel
{
    /// <summary>
    /// Allgemeine Oberklasse für alle Objekte im Spiel
    /// </summary>
    public class GameObject
    {
        #region Private fields

        protected Vector2 center;           // Position des Objektes (Mittelpunkt)
        protected TextureData textureData;  // Textur des Objektes
        protected int worldSize;            // Größe des Spielfeldes

        #endregion Private fields

        #region Public properties

        public Vector2 Center
        {
            get { return this.center; }
            set { this.center = value; }
        }

        #endregion Public properties

        #region Construction

        /// <summary>
        /// Standardkonstruktor
        /// </summary>
        protected GameObject()
        {
        }

        /// <summary>
        /// Konstruktor
        /// </summary>
        /// <param name="newTexture"></param>
        /// <param name="newCenter"></param>
        /// <param name="newWorldSize"></param>
        public GameObject(TextureData newTextureData, Vector2 newCenter, int newWorldSize)
        {
            this.textureData = newTextureData;
            this.center = newCenter;
            this.worldSize = newWorldSize;
        }

        #endregion Construction

        #region Public methods

        /// <summary>
        /// Update-Methode
        /// </summary>
        public void Update()
        {
        }

        /// <summary>
        /// Draw-Methode
        /// </summary>
        /// <param name="spriteBatch">Spritebatch</param>
        public void Draw(SpriteBatch spriteBatch, float xOffset = 0f, float yOffset = 0f)
        {
            Rectangle destinationRectangle = new Rectangle((int)(center.X - textureData.halfwidth), (int)(center.Y - textureData.halfheight), textureData.width, textureData.height);
            spriteBatch.Draw(textureData.texture, destinationRectangle, Color.White);
        }

        #endregion Public methods
    }
}
